/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Client;

import java.io.*;
import java.net.UnknownHostException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
/*
 *
 * @author sajin 
 */
public class DHT {
	void put(byte[] key) {
	}
	boolean publishFile( String filePath ) throws FileNotFoundException, UnknownHostException {
		File file = new File ( filePath );
		CentralServer S = new CentralServer("127.0.0.1");

		if (file.exists()){
			String fileName = file.getName();
			try {
				MessageDigest sha = MessageDigest.getInstance("SHA-1");
				sha.update(fileName.getBytes());

				String[] neighbourNodes = S.findNodes(new String( sha.digest() ));

			} catch ( NoSuchAlgorithmException nexpAlg ) {
				System.err.println( nexpAlg.getCause() );
				return false;
			}

		}
		else
			throw new FileNotFoundException();

		return true;
	}
}
